﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Management;
using System.Threading;

namespace ConsoleApplication4
{
    class DisplayProcessor
    {

        static public PerformanceCounter cpuUsage;
        static public PerformanceCounter ramCounter;
        
        static public void Processor2()
        {

            for (int i = 0; i < 1; i++)
            {
                cpuUsage = new PerformanceCounter("Processor Information", "% Processor Time", "_Total");
                ramCounter = new PerformanceCounter("Memory", "Available MBytes");

                string timestamp = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff tt");
                string timestampp = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff tt");
                int Numbits = 1024;
                double fire = (double)Math.Floor(ramCounter.NextValue());
                double typee = Convert.ToDouble(fire / (Numbits));
 
                //Pulls the computer CPU usage and memory that is avialible ath his specific time. 
                Console.WriteLine("Start" + " " + "CPU usage" + " " + cpuUsage.NextValue() + " %");
                Console.WriteLine("Start" + " " + "RAM" + " " + typee.ToString(".00") + "GB");
                Console.WriteLine(" ");
                Console.WriteLine("Calculated to Milliseconds" + " " + timestampp);            
                Thread.Sleep(5000);
                Console.WriteLine(" ");
                Console.WriteLine("After 5 seconds!");
                Console.WriteLine(" ");
                Console.WriteLine("Finsh" + " " + "CPU usage" + " " + cpuUsage.NextValue() + " %");
                Console.WriteLine("Finsh" + " " + "RAM" + " " + typee.ToString(".00") + "GB");
                Console.WriteLine(" ");
                Console.WriteLine("Calculated to Milliseconds" + " " + timestamp);

                //Tells the user that the results are going back to the top of the graph. 
                Console.WriteLine("Restarts Process");

            }
        }
      
    }
    }

